import 'package:flutter/material.dart';
import '../models/word_book.dart';

class BookInfoWidget extends StatelessWidget {
  final WordBook book;
  final VoidCallback onMoreBooks;

  const BookInfoWidget({
    Key? key,
    required this.book,
    required this.onMoreBooks,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16.0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16.0),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            blurRadius: 10,
            offset: const Offset(0, 5),
          ),
        ],
      ),
      child: Row(
        children: [
          // 词书封面
          ClipRRect(
            borderRadius: BorderRadius.circular(8.0),
            child: Image.network(
              book.coverImage,
              width: 80,
              height: 100,
              fit: BoxFit.cover,
              errorBuilder: (context, error, stackTrace) {
                return Container(
                  width: 80,
                  height: 100,
                  color: Colors.grey[300],
                  child: const Icon(Icons.book, size: 40),
                );
              },
            ),
          ),
          const SizedBox(width: 16.0),
          // 词书信息
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  book.name,
                  style: const TextStyle(
                    fontSize: 18.0,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                const SizedBox(height: 4.0),
                Text(
                  '${book.totalWords} 个单词',
                  style: TextStyle(
                    fontSize: 14.0,
                    color: Colors.grey[600],
                  ),
                ),
                const SizedBox(height: 4.0),
                Text(
                  book.description,
                  style: TextStyle(
                    fontSize: 12.0,
                    color: Colors.grey[600],
                  ),
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                ),
              ],
            ),
          ),
          // 更多词书按钮
          IconButton(
            icon: const Icon(Icons.menu_book),
            onPressed: onMoreBooks,
            tooltip: '更多词书',
          ),
        ],
      ),
    );
  }
} 